# encoding=utf-8
import yaml

apiData1 = {
    "page": 1,
    "msg": "地址",
    "data": [{
        "id": 1,
        "name": "学校"
    }, {
        "id": 2,
        "name": "公寓"
    }, {
        "id": 3,
        "name": "流动人口社区"
    }],
}

apiData2 = {
    "page": 2,
    "msg": "地址",
    "data": [{
        "id": 1,
        "name": "酒店"
    }, {
        "id": 2,
        "name": "医院"
    }, {
        "id": 3,
        "name": "养老院"
    }],
}

with open('writeYamlData.yml', 'w', encoding= 'utf-8') as f:
    yaml.dump_all(documents=[apiData1, apiData2], stream=f, allow_unicode=True)

with open('writeYamlData.yml', 'r', encoding= 'utf-8') as f:
    result = yaml.load_all(f.read(), Loader=yaml.FullLoader)
    print(result, type(result))
    for i in result:
        print(i)
